[ASP.NET] Odd HttpRequest behaviour
Posted
by barguast
on Stack Overflow
See other posts from Stack Overflow
or by barguast
Published on 2010-03-26T16:29:34Z
Indexed on
2010/03/26
16:33 UTC
Read the original article
Hit count: 596
I have a web service which runs with a HttpHandler class. In this class, I inspect the request stream for form / query string parameters. In some circumstances, it seemed as though these parameters weren't getting through. After a bit of digging around, I came across some behaviour I don't quite understand. See below:
// The request contains 'a=1&b=2&c=3' // TEST ONLY: Read the entire request string contents; using (StreamReader sr = new StreamReader(context.Request.InputStream)) { contents = sr.ReadToEnd(); } // Here 'contents' is usually correct - containing 'a=1&b=2&c=3'. Sometimes it is empty. string a = context.Request["a"]; // Here, a = null, regardless of whether the 'contents' variable above is correct
Can anyone explain to me why this might be happening? I'm using a .NET WebClient and UploadDataAsync to perform the request on the client if that makes any difference.
If you need any more information, please let me know.
© Stack Overflow or respective owner